<template>
    <div>
        <#list clazz.fields as field>
        <el-row class="item">
            <el-col :span="5" class="center">${field.remark}</el-col>
           <#if field.type=="Date">
            <el-col :span="19">{{form.${field.name} | formatDateLong}}</el-col>
           <#else >
            <el-col :span="19">{{form.${field.name}}}</el-col>
           </#if>
        </el-row>
        </#list>
    </div>
</template>

<script>
    import moment from 'moment';

    export default {
        name: 'admin-show',
        props: {
            tId: Number,
            tForm: Object
        },
        data() {
            return {
                showUrl: '/${projectName}/restpage/${clazz.name?uncap_first}/get', //数据地址
                form: this.tForm
            }
        },
        watch: {
            tForm(v) {
                this.form = v;
            }
        },
        methods: {
            showById(){
                if (this.tId && this.tId !== -1 && this.tId !== 0) {
                    this.$http.get(this.showUrl, {
                        id: this.tId
                    }).then(res => {
                        this.form = res;
                    });
                }
            }
        },
        filters: {
            //时间格式过滤器
            formatDateLong: function (value) {
                if (!value) {
                    return '';
                }
                return moment(value).format('YYYY-MM-DD HH:mm:ss');
            }
        }
    };
</script>

<style scoped>
    .center {
        text-align: center;
    }

    .item{
        margin-bottom: 15px;
    }
</style>